<?php
class Factura extends AppModel {
	var $name = 'Factura';
	var $useTable = 'facturas';
	var $validate = array(
		'id' => array(
			'blank' => array(
				'rule' => array('blank'),
				'on' => 'create' 
			)
		),
		'persona_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'usuario_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'observacion' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '500')
			)
		),
		'created' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'escurso' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'anulada' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'vto' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		)
	);

	var $belongsTo = array(
		'Persona' => array(
			'className' => 'Persona',
			'foreignKey' => 'persona_id'
		),
		'Usuario' => array(
			'className' => 'Persona',
			'foreignKey' => 'usuario_id'
		)
	);

	var $hasMany = array(
		'FacturaCurso' => array(
			'className' => 'FacturaCurso',
			'foreignKey' => 'factura_id'
		),
		'FacturaPago' => array(
			'className' => 'FacturaPago',
			'foreignKey' => 'factura_id'
		),
		'FacturaVenta' => array(
			'className' => 'FacturaVenta',
			'foreignKey' => 'factura_id'
		),
		'RecordatorioCartaPago' => array(
			'className' => 'RecordatorioCartaPago',
			'foreignKey' => 'factura_id'
		)
	);
}
?>